<template>
  <a-modal
    title="请选择审批人"
    :visible="showApproveConfirm"
    :confirm-loading="confirmLoading"
    ok-text='确认提交审核'
    @ok="submitApprove"
    @cancel="approveCancel"
  >
    <a-select
      show-search
      placeholder="请选择"
      option-filter-prop="children"
      style="width: 200px"
      title='请选择审批人'
      @change="selectApprover"
    >
      <a-select-option v-for='(item,index) in approverList' :key='item.id' :value="item.id">
        {{item.realname}}
      </a-select-option>
    </a-select>
  </a-modal>
</template>

<script>
import { httpAction, getAction, postAction, deleteAction } from '@/api/manage'

export default {
  name: 'UserModal',
  components: {

  },
  props: {
    proId: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      approverList:'',//审批人列表
      confirmLoading: false,
      showApproveConfirm:false,
      url: {
        getApprover:'/sys/user/queryAuditInfoByOrgCode',
        addApprove:'/sjzyzhgl/sjApplyLog/add',// 添加审批
      },
    }
  },
  created() {
    this.showApproverModal()
  },
  computed: {
    uploadAction: function() {
      return this.url.fileUpload
    }
  },
  methods: {
    submitApprove() {
      postAction(this.url.addApprove, {
        pid: this.proId,
        userids:this.approverId,
        stage:'0',
        type:'10'
      }).then((res) => {
        if (res.success && res.result) {
          this.$emit('setStatus','1','2')
          // this.setStatus('1','2')
        } else {

        }
      })
    },
    approveCancel(e) {
      this.showApproveConfirm = false;
    },
    selectApprover(val){
      this.approverId = val
    },
    //提交审批选择审批人并确认弹窗
    showApproverModal() {
      getAction(this.url.getApprover).then((res) => { //获取审核人列表
        if (res.success && res.result) {
          this.approverList = res.result
        } else {
          console.log(res)
        }
      }).finally(() => {
      })
    },
  }
}
</script>

<style scoped>

</style>
